package core;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by taohj on 2014/12/19.
 */
public abstract class ServletBase extends HttpServlet {


    public void print(HttpServletResponse response, String str) throws IOException {
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        out.print(str);
        out.flush();
        out.close();
    }

    public  void setCurrentFilePath(HttpServletRequest request,String filePath){
        request.getSession().setAttribute("filepath",filePath);
    }

    public  String  getCurrentFilePath(HttpServletRequest request){

        return  request.getSession().getAttribute("filepath")+"";
    }


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       this.doPost(req, resp);
    }
}
